package com.webware.view.client.app;

import com.google.gwt.user.client.ui.IsWidget;
import com.mvp4g.client.annotation.Debug;
import com.mvp4g.client.annotation.Event;
import com.mvp4g.client.annotation.Events;
import com.mvp4g.client.annotation.InitHistory;
import com.mvp4g.client.annotation.Start;
import com.mvp4g.client.annotation.module.ChildModule;
import com.mvp4g.client.annotation.module.ChildModules;
import com.mvp4g.client.annotation.module.DisplayChildModuleView;
import com.mvp4g.client.event.EventBusWithLookup;
import com.webware.view.client.admin.AdminModule;
import com.webware.view.client.admin.presenter.AdminPagePresenter;
import com.webware.view.client.app.presenter.AppPresenter;
import com.webware.view.client.app.presenter.HeaderPresenter;
import com.webware.view.client.main.presenter.MainPagePresenter;

@Events(startPresenter = AppPresenter.class, historyOnStart = true)
@Debug
@ChildModules({ @ChildModule(moduleClass = AdminModule.class, async = false, autoDisplay = false) })
public interface AppEventBus extends EventBusWithLookup {

    @Start
    @Event(bind = { HeaderPresenter.class })
    void start();

    @InitHistory
    @Event(handlers = AppPresenter.class)
    void init();

    /*
     * Layout events
     */
    @Event(handlers = AppPresenter.class)
    void setBody(IsWidget body);

    @DisplayChildModuleView(AdminModule.class)
    @Event(handlers = AppPresenter.class)
    void changeBody(IsWidget newBody);

    /*
     * Place events
     */
    @Event(handlers = MainPagePresenter.class, historyConverter = AppHistoryConverter.class, name = "main")
    void goToMainPage(String name);

    @Event(handlers = { AdminPagePresenter.class }, historyConverter = AppHistoryConverter.class, name = "admin")
    void goToAdminPage(String name);

    @Event(handlers = { AppPresenter.class }, historyConverter = AppHistoryConverter.class)
    void goBack();
}
